<template>
  <div>
    <el-form
      :inline="true"
      :model="formInline"
      class="demo-form-inline"
      style="text-align: left"
    >
      <el-form-item label="设备名称">
        <el-input
          v-model="formInline.equipmentName"
          placeholder="设备名称"
        ></el-input>
      </el-form-item>
      <el-form-item label="处理状态">
        <el-select v-model="formInline.status" placeholder="处理状态">
          <el-option label="请选择" value=""></el-option>
          <el-option label="已处理" value="true"></el-option>
          <el-option label="待处理" value="false"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button
          style="background-color: green; color: white"
          icon="el-icon-search"
          @click="list"
          >查询</el-button
        >
        <el-button style="color: gray" icon="el-icon-refresh">重置</el-button>
      </el-form-item>
    </el-form>
    <template>
      <el-table
        :data="tableData"
        border
        style="width: 100%"
        :row-class-name="tableRowClassName"
      >
        <el-table-column prop="id" label="序号" align="center">
        </el-table-column>
        <el-table-column prop="alarmCode" label="事件编号" align="center">
        </el-table-column>
        <el-table-column prop="equipmentName" label="设备名称" align="center">
        </el-table-column>
        <el-table-column prop="equipmentNum" label="设备编号" align="center">
        </el-table-column>
        <el-table-column prop="deviceTypeId" label="设备类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.deviceTypeId == 1">出入口</span>
            <span v-if="scope.row.deviceTypeId == 2">出入口</span>
          </template>
        </el-table-column>
        <el-table-column prop="alarmTypeId" label="告警类型" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.alarmTypeId == 1">车辆告警</span>
            <span v-if="scope.row.alarmTypeId == 2">车辆告警</span>
          </template>
        </el-table-column>
        <el-table-column prop="alarmTime" label="告警时间" align="center">
        </el-table-column>
        <el-table-column prop="alarmSeverity" label="告警级别" align="center">
        </el-table-column>

        <el-table-column prop="picture" label="图片" align="center">
          <el-image :src="src" style="width: 30px; height: 30px"></el-image>
        </el-table-column>
        <el-table-column prop="status" label="处理状态" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.status == true" style="color: green"
              >已处理</span
            >
            <span v-if="scope.row.status == false" style="color: red"
              >待处理</span
            >
          </template>
        </el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button type="text" style="color: green" @click="upd(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </template>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="formInline.pageIndex"
      :page-sizes="[1, 2, 3, 4]"
      :page-size="formInline.pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="countnum"
    >
    </el-pagination>

    <el-dialog width="600px" title="详情信息" :visible.sync="dialogFormVisible">
      <el-form
        ref="form"
        :model="form"
        :rules="rules"
        label-width="180px"
        style="width: 600px; margin: 2px auto"
      >
        <el-form-item label="事件编号" prop="equipmentCoding">
          {{ form.alarmCode }}
        </el-form-item>
        <el-form-item label="设备名称" prop="originalNum">
          {{ form.equipmentName }}
        </el-form-item>
        <el-form-item label="设备编号" prop="equipmentName">
          {{ form.equipmentNum }}
        </el-form-item>
        <el-form-item label="设备类型" prop="equipmentLocaId">
          {{ form.deviceTypeId }}
          <template slot-scope="scope">
            <span v-if="scope.row.deviceTypeId == 1">出入口</span>
            <span v-if="scope.row.deviceTypeId == 2">出入口</span>
          </template>
        </el-form-item>
        <el-form-item label="告警类型" prop="deviceType">
          {{ form.alarmTypeId }}
          <template slot-scope="scope">
            <span v-if="scope.row.alarmTypeId == 1">车辆告警</span>
            <span v-if="scope.row.alarmTypeId == 2">车辆告警</span>
          </template>
        </el-form-item>
        <el-form-item label="告警时间" prop="detailedLocation">
          {{ form.alarmTime }}
        </el-form-item>
        <el-form-item label="告警级别" prop="equipmentModel">
          {{ form.alarmSeverity }}
        </el-form-item>
        <el-form-item label="图片" prop="equipmentBrand">
          <el-image :src="src" style="width: 30px; height: 30px"></el-image>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>
<script>
import { GetAlarmRecordPage, GetCount } from "@/api/area/Police";
export default {
  data() {
    return {
      tableRowClassName({ row, rowIndex }) {
        if (rowIndex === 0) {
          return "warning-row";
        } else if (rowIndex === 2) {
          return "success-row";
        }
        return "";
      },
      src: "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
      tableData: [],
      dialogFormVisible: false,
      ids: {},
      form: {
        alarmCode: "",
        equipmentName: "",
        equipmentNum: "",
        deviceTypeId: "",
        alarmTypeId: "",
        alarmTime: "",
        alarmSeverity: "",
        faceImage: "",
      },
      formInline: {
        pageIndex: 1,
        pageSize: 2,
        equipmentName: "",
        status: "",
      },
      countnum: 0,
      count: 0,
    };
  },
  created() {
    this.list();
    this.totalcount();
  },
  methods: {
    //显示
    list() {
      GetAlarmRecordPage(this.formInline).then((res) => {
        this.tableData = res.data.data;
        this.count = res.data.totalCount;
      });
    },
    handleSizeChange(val) {
      this.formInline.pageSize = val;
      this.list();
    },
    handleCurrentChange(val) {
      this.formInline.pageIndex = val;
      this.list();
    },
    totalcount() {
      GetCount().then((res) => {
        this.countnum = res.data;
      });
    },
    //修改
    upd(row) {
      this.dialogFormVisible = true;
      this.form = row;
    },
  },
};
</script>
<style>
</style>